package com.project.config;


import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpHeaders;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Configuration
public class MyMVConfiger  implements WebMvcConfigurer {

    @Bean
    public WebMvcConfigurer crosConfiger(){
        return new WebMvcConfigurer() {
            @Override
            public void addCorsMappings(CorsRegistry registry) {
                registry.addMapping("/**")//允许服务器端的哪些url处理跨域
                        .allowedOrigins("*")//允许哪些请求域
                        .allowedMethods("*")//允许哪些请求方式
                        .allowedHeaders("*");
                // exposedHeaders(HttpHeaders.SET_COOKIE).maxAge(5);;//允许哪些请求头
            }
        };

    }
}
